import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: '1' }
    }]
  },
  {
    path: '/column',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Form',
        component: () => import('@/pages/column/List'),
        meta: { title: '栏目管理', icon: '2' }
      }
    ]
  },
  {
    path: '/product',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Product',
        component: () => import('@/pages/product/List'),
        meta: { title: '产品管理', icon: '3' }
      }
    ]
  },
  {
    path: '/audit',
    component: Layout,
    redirect: '/audit/table',
    name: 'Audit',
    meta: { title: '审核大厅', icon: '4' },
    children: [
      {
        path: 'authentication',
        name: 'Authentication',
        component: () => import('@/pages/audit/authentication'),
        meta: { title: '实名认证',}
      },
      {
        path: 'account',
        name: 'Account',
        component: () => import('@/pages/audit/account'),
        meta: { title: '账户变更',}
      },
      {
        path: 'Infocomments',
        name: 'Infocomments',
        component: () => import('@/pages/audit/Infocomments'),
        meta: { title: '资讯评论', }
      },
      {
        path: 'ordercomments',
        name: 'Ordercomments',
        component: () => import('@/pages/audit/ordercomments'),
        meta: { title: '订单评论',}
      }
    ]
  },
  {
    path: '/bill',
    component: Layout,
    redirect: '/audit/customer',
    name: 'Bill',
    meta: { title: '账单管理', icon: '5' },
    children: [
      {
        path: 'customer',
        name: 'Customer',
        component: () => import('@/pages/bill/customer'),
        meta: { title: '顾客账单',}
      },
      {
        path: 'employee',
        name: 'Employee',
        component: () => import('@/pages/bill/employee'),
        meta: { title: '员工账单',}
      },
      {
        path: 'system',
        name: 'System',
        component: () => import('@/pages/bill/system'),
        meta: { title: '系统账单',  }
      },
      {
        path: 'recharge',
        name: 'Recharge',
        component: () => import('@/pages/bill/recharge'),
        meta: { title: '充值',  }
      },
      
    ]
  },
  {
    path: '/order',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Order',
        component: () => import('@/pages/order/List'),
        meta: { title: '订单管理', icon: '6' }
      }
    ]
  },
  {
    path: '/customer',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Customer',
        component: () => import('@/pages/customer/List'),
        meta: { title: '顾客管理', icon: '7' }
      }
    ]
  },
  {
    path: '/employee',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Employee',
        component: () => import('@/pages/employee/List'),
        meta: { title: '员工管理', icon: '8' }
      }
    ]
  },
  {
    path: '/information',
    component: Layout,
    redirect: '/information/classification',
    name: 'Bill',
    meta: { title: '网站资讯', icon: '9' },
    children: [
      {
        path: 'classification',
        name: 'Classification',
        component: () => import('@/pages/information/classification'),
        meta: { title: '资讯分类',}
      },
      {
        path: 'info',
        name: 'Info',
        component: () => import('@/pages/information/info'),
        meta: { title: '资讯信息', }
      },
      
    ]
  },
  {
    path: '/permissions',
    component: Layout,
    // redirect: '/information/classification',
    name: 'Permissions',
    meta: { title: '角色权限', icon: '10' },
    children: [
      {
        path: 'management',
        name: 'Management',
        component: () => import('@/pages/permissions/management'),
        meta: { title: '权限管理', }
      },
      {
        path: 'user',
        name: 'User',
        component: () => import('@/pages/permissions/user'),
        meta: { title: '用户管理', }
      },
      {
        path: 'roles',
        name: 'Roles',
        component: () => import('@/pages/permissions/roles'),
        meta: { title: '角色管理', }
      },
    ]
  },
  {
    path: '/log',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Log',
        component: () => import('@/pages/log/List'),
        meta: { title: '日志管理', icon: '11' }
      }
    ]
  },
  {
    path: '/shuffling',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Shuffling',
        component: () => import('@/pages/shuffling/List'),
        meta: { title: '轮播管理', icon: '12' }
      }
    ]
  },
  {
    path: '/configuration',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Configuration',
        component: () => import('@/pages/configuration/List'),
        meta: { title: '系统配置', icon: '13' }
      }
    ]
  },
  {
    path: '/personal',
    component: Layout,
    children: [
      {
        path: 'List',
        name: 'Personal',
        component: () => import('@/pages/personal/List'),
        meta: { title: '个人信息', icon: '14' }
      }
    ]
  },
  
  

  

  

 

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
